package org.HisCanvas.ChrisRiffle.JFlightLog.swingUi.recordDetailWindow;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JDialog;




public class LogBookRecDialog extends JDialog{
	
	
	private static final Dimension DIALOG_SIZE = new Dimension(400,450);
	
	
	private LogBookRecPanel recPanel;
	
	private LogBookRecOkCancelButtonPanel okCancelButtonPanel;
	
	 
	
	public LogBookRecDialog() {
		init();
	}
	
	
		
	
	private void init() {
		
		setModal(true);
		setModalityType(ModalityType.APPLICATION_MODAL);
		//don't set 'always on top'/true b/c it messes up popups off the 
		// rec detail window
		
		
		Container c = getContentPane();		
		GroupLayout groupLayout = new GroupLayout(c);		
		c.setLayout(groupLayout);
		
		groupLayout.setAutoCreateContainerGaps(true);
		
		
		groupLayout.setHorizontalGroup(groupLayout.createParallelGroup()
		  .addComponent(getRecPanel())
		  .addComponent(getOkCancelButtonPanel(), Alignment.TRAILING)		
		);
		
		
		groupLayout.setVerticalGroup(groupLayout.createSequentialGroup()
		  .addComponent(getRecPanel())
		  .addGap(10)
		  .addComponent(getOkCancelButtonPanel())		 		
		);
						
		
		setPreferredSize(DIALOG_SIZE);
		pack();
	}
	
	
	
	public LogBookRecPanel getRecPanel(){
		
		if(recPanel == null){
			
			recPanel = new LogBookRecPanel();
		}
		return recPanel;
	}
	
	
	public LogBookRecOkCancelButtonPanel getOkCancelButtonPanel(){
		
		if(okCancelButtonPanel == null){
			
			okCancelButtonPanel = new LogBookRecOkCancelButtonPanel();			
		}
		return okCancelButtonPanel;
		
	}
	
	
	public static void main(String[] args) {
		
		LogBookRecDialog d = new LogBookRecDialog();
		d.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {			
				System.exit(0);
			}
		});
		d.setLocationRelativeTo(null);
		d.setVisible(true);
	} 

}



